package com.example.blog.exception;

/**
 * @Classname BusinessExceptions
 * @Description TODO 自定义异常类
 * @Version 1.0.0
 * @Date 2023/1/26 12:28
 * @Created by wlh12
 */
public class BusinessException extends RuntimeException {
    private Integer code;
    private String errors;

    public BusinessException() {
        this.code = CommonErrorCode.BUSINESS_ERROR.getCode();
        this.errors = CommonErrorCode.BUSINESS_ERROR.getMessage();
    }

    public BusinessException(String message) {
        super(message);
        this.code = CommonErrorCode.BUSINESS_ERROR.getCode();
        this.errors = message;
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.code = CommonErrorCode.BUSINESS_ERROR.getCode();
        this.errors = message;
    }

    public BusinessException(Throwable cause) {
        super(cause);
        this.code = CommonErrorCode.BUSINESS_ERROR.getCode();
        this.errors = cause.getMessage();
    }

    public BusinessException(String message, Integer code) {
        super(message);
        this.code = CommonErrorCode.BUSINESS_ERROR.getCode();
        this.errors = message;
    }

    public BusinessException(String message, Throwable cause, Integer code) {
        super(message, cause);
        this.code = code;
        this.errors = message;
    }

}

